#include <stdio.h>
#include "graph.h"

//图的深度优先和广度优先搜索
#if 1
int main(void)
{
	Graph graph;
	char vertex;

	Init(&graph);

	for (char i = 'A'; i <= 'H'; i++)
		InsertVertex(&graph, i);

	InsertEdge(&graph, 'A', 'B');
	InsertEdge(&graph, 'A', 'C');
	InsertEdge(&graph, 'B', 'D');
	InsertEdge(&graph, 'B', 'E');
	InsertEdge(&graph, 'C', 'F');
	InsertEdge(&graph, 'C', 'G');
	InsertEdge(&graph, 'D', 'H');
	InsertEdge(&graph, 'E', 'H');
	InsertEdge(&graph, 'F', 'G');
	Show(&graph);

	vertex = 'D';
	printf("从%c开始的深度优先遍历结果：", vertex);
	DFS(&graph, vertex);
	printf("\n");

	vertex = 'A';
	printf("从%c开始的广度优先遍历结果：", vertex);
	BFS(&graph, 'A');
	printf("\n");

	return 0;
}
#endif

//非连通图的遍历
#if 0
int main(void)
{
	Graph graph;

	Init(&graph);

	for (char i = 'A'; i <= 'M'; i++)
		InsertVertex(&graph, i);

	InsertEdge(&graph, 'A', 'B');
	InsertEdge(&graph, 'A', 'L');
	InsertEdge(&graph, 'A', 'F');
	InsertEdge(&graph, 'A', 'C');
	InsertEdge(&graph, 'L', 'J');
	InsertEdge(&graph, 'L', 'M');
	InsertEdge(&graph, 'B', 'M');
	InsertEdge(&graph, 'J', 'M');

	InsertEdge(&graph, 'D', 'E');

	InsertEdge(&graph, 'G', 'H');
	InsertEdge(&graph, 'G', 'I');
	InsertEdge(&graph, 'G', 'K');
	InsertEdge(&graph, 'K', 'H');

	Show(&graph);

	printf("非连通图的深度优先遍历结果：");
	Connection(&graph);

	Destory(&graph);

	return 0;
}
#endif